home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Commands / PasteFireworksHTML.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  1.4 KB  |  60 lines

  1. // Copyright 1999 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS  *****************
  4.  
  5. var USE_SITE_RELATIVE = false;
  6.  
  7.  
  8. //******************* LOCAL FUNCTIONS **********************
  9.  
  10. function initialize() {
  11.   MM.event.handled = pasteFWHTML();
  12. }
  13.  
  14.  
  15. function pasteFWHTML() {
  16.   var result, validFWFile=false;
  17.   var fwURL, fwSource, fwDOM;
  18.   var docURL, docDOM, siteURL, parentFile, docRootURL, siteRootURL;
  19.  
  20.   fwSource = dw.getClipboardText();
  21.  
  22.   if (fwSource && isFireworksHTML(fwSource)) {
  23.     validFWFile = true;
  24.     if (!isDWStyle(fwSource))
  25.       alert(MSG_notExportedForDW);
  26.     else if (!usesDWBehaviors(fwSource))
  27.       alert(MSG_behNotSupported);
  28.   }
  29.  
  30.   if (validFWFile) {
  31.     fwURL = dw.getConfigurationPath() + "/Shared/MM/Cache/empty.htm";
  32.     DWfile.write(fwURL,'');
  33.     fwDOM = dw.getDocumentDOM(fwURL);
  34.     fwDOM.body.innerHTML = fwSource;
  35.     docURL = dw.getDocumentPath("document");
  36.     siteURL = dw.getSiteRoot();
  37.  
  38.     docRootURL = '';
  39.     siteRootURL = '';
  40.     if (docURL) {
  41.       parentFile = new File(docURL);
  42.       docRootURL = parentFile.getAbsoluteParent() + File.separator;
  43.       if (USE_SITE_RELATIVE) {
  44.         parentFile = new File(siteURL);
  45.         siteRootURL = parentFile.getAbsolutePath();
  46.       }
  47.     }
  48.  
  49.     theHTML = insertFireworksHTML(fwDOM, fwURL, docRootURL, siteRootURL);
  50.  
  51.     dw.releaseDocument(fwDOM);
  52.  
  53.     docDOM = dw.getDocumentDOM('document');
  54.     docDOM.insertHTML(theHTML);
  55.   }
  56.  
  57.   return validFWFile;
  58. }
  59.  
  60.